package com.woniu.springboot.service.serviceImpl;

import com.woniu.springboot.entity.Employee;
import com.woniu.springboot.mapper.EmployeeMapper;
import com.woniu.springboot.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public Collection<Employee> findEmployeeAll() {
        return employeeMapper.getAll();
    }

    @Override
    public Employee findEmployeeByKey(Integer id) {
        return employeeMapper.get(id);
    }

    @Override
    public int removeEmployeeByKey(Integer id) {
        return employeeMapper.delete(id);
    }

    @Override
    public int addEmployee(Employee employee) {
        return employeeMapper.insert(employee);
    }

    @Override
    public List<Employee> findEmployeeByName(String name) {
        return employeeMapper.selectEmployeeByName(name);
    }

    @Override
    public int modifyEmployeeByKey(Employee employee) {
        return employeeMapper.update(employee);
    }
}
